//
//  JNSearchView.swift
//  SinaWeibo
//
//  Created by 9264 on 16/9/19.
//  Copyright © 2016年 LY9264. All rights reserved.
//

import UIKit

class JNSearchView: UIView {

    @IBOutlet weak var searchTextFieldRightConstraint: NSLayoutConstraint!
    
    @IBOutlet weak var searchButton: UIButton!

    @IBOutlet weak var searchTextField: UITextField!
    
    
    @IBAction func editBeginAction(_ sender: AnyObject) {
        searchTextFieldRightConstraint.constant = searchButton.width + 15
        
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
    }
    
    }
    
    @IBAction func searchButtonAction(_ sender: AnyObject) {
        searchTextField.resignFirstResponder()
        searchTextFieldRightConstraint.constant = 0
        UIView.animate(withDuration: 0.3) {
        self.layoutIfNeeded()
    }
    }
    
    class func searchView() -> JNSearchView {
        
        return UINib(nibName: "JNSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as! JNSearchView
    }
    
        override func awakeFromNib() {
            searchTextField.layer.borderColor = UIColor.green.cgColor
            searchTextField.layer.borderWidth = 2
            searchTextField.layer.cornerRadius = 15
            searchTextField.layer.masksToBounds = true
            searchButton.setTitle("搜索", for: .normal)
        }
}
